package com.example.apprendrechinois.cours;

import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.example.apprendrechinois.MainActivity;
import com.example.apprendrechinois.R;
import com.example.apprendrechinois.avis.Avis;

import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class CoursListe extends ListActivity {
		
	    private TextView text; 
		
	    private String [] cours = { "Cours1", "Cours2", "Cours3", "Cours4","Cours5",
	    							"Cours6", "Cours7", "Cours8", "Cours9", "Cours10",
	    							"Cours11", "Cours12", "Cours13", "Cours14", "Cours15",
	    							"Cours16", "Cours17", "Cours18", "Cours19", "Cours20"};
		

	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);	        
	        setContentView(R.layout.cours_liste);
	        
	        setListAdapter(new ArrayAdapter<String>(this, R.layout.courssimple, cours));
	        getListView().setOnItemClickListener(new OnItemClickListener() {

				@Override
				public void onItemClick(AdapterView<?> arg0, View arg1,
						int arg2, long arg3) {
					System.out.println("position ? :) "+arg2);
					Intent intentListe = new Intent();
					intentListe.setClass(CoursListe.this, Cours.class);
					Bundle bundle = new Bundle();
					bundle.putInt("number", arg2);
					intentListe.putExtras(bundle);
					startActivity(intentListe);
					
				}
			});
	        
	  }
	    
	    
	    public void woDeNiuniu(){
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setMessage("Est-ce que tu aimes Niuniu?")
			       .setCancelable(false)
			       .setPositiveButton("Oui", new DialogInterface.OnClickListener() {
			           public void onClick(DialogInterface dialog, int id) {
			        	   CoursListe.this.finish();
			           }
			       })
			       .setNegativeButton("Non", new DialogInterface.OnClickListener() {
			           public void onClick(DialogInterface dialog, int id) {
			                dialog.cancel();
			           }
			       });
			AlertDialog alert = builder.create();
			alert.show();
	    }
	    
	

}
